package com.adlotto2.android.util;

import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.drawable.Drawable;

public class LottoAdOverButton {
	public LottoAdOverButton() {
	}

	public static Drawable grayimg(Drawable d) {

		ColorMatrix matrix = new ColorMatrix();
//		matrix.setSaturation((float) 0.2); // 0 : 완전 회색, 1: 그대로 0~1 사이 숫자로 회색
											// 정도를 정할 수 있다.
		
		setContrastTranslateOnly(matrix, -0.4f);
		
		ColorMatrixColorFilter cf = new ColorMatrixColorFilter(matrix);
		
		d.setColorFilter(cf);
		return d;
	}

	 private static void setContrastTranslateOnly(ColorMatrix cm, float contrast) {
         float scale = contrast + 1.f;
            float translate = (-.5f * scale + .5f) * 255.f;
         cm.set(new float[] {
                1, 0, 0, 0, translate,
                0, 1, 0, 0, translate,
                0, 0, 1, 0, translate,
                0, 0, 0, 1, 0 });
     }
}
